package com.atguigu.classroom.live.api;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.classroom.live.service.LiveCourseService;
import com.atguigu.classroom.result.Result;
import com.atguigu.classroom.utils.AuthContextHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "直播权限接口")
@RestController
@RequestMapping("api/live/liveCourse")
public class LiveCourseApiController {
    @Autowired
    private LiveCourseService liveCourseService;

    @ApiOperation("获取用户access_token")
    @GetMapping("getPlayAuth/{id}")
    public Result<JSONObject> getPlayAuth(@PathVariable Long id) {
        Long userId = AuthContextHolder.getUserId();
        System.out.println("用户id是不是用户表主键？"+userId);
        JSONObject object=liveCourseService.getAccessToken(id,userId);
        return Result.ok(object);
    }
}
